﻿package com;

import java.util.HashMap;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.Transaction;

public class Text01_Redis {	

	public static void main(String[] args) {
		//dddds
		
		/*Jedis jedis = new Jedis("192.168.119.128");
		jedis.set("name", "詹少干");
		System.out.println(jedis.get("name"));*/
		text();
		
	}
	public static void text(){
		//获得连接池的配置对象
		JedisPoolConfig con = new JedisPoolConfig();
		//设置最大连接数
		con.setMaxTotal(30);
		//设置最大空闲连接数
		con.setMaxIdle(10);
		//获取连接池
		JedisPool jedisPool =new JedisPool(con,"192.168.119.128");
		//创建对象
		Jedis jedis=null;	
		try {
			//通过连接池获得连接
			jedis =jedisPool.getResource();
			//储存数据
			jedis.set("ddd","dsadsa");
			//获取数据
			System.out.println(jedis.get("ddd"));
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			//释放资源
			if(jedis!=null){
				jedis.close();
			}
			if(jedisPool!=null){
				jedisPool.close();
			}
		}
	}
}
